package com.tanhua.server.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.common.mapper.BlackListMapper;
import com.tanhua.common.pojo.BlackList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.management.Query;

@Service
public class BlacklistService {

    @Autowired
    private BlackListMapper blackListMapper;


    /**
     * 获取黑名单列表
     *
     * @param userId
     * @param page
     * @param pageSize
     * @return
     */
    public IPage<BlackList> queryBlacklist(Long userId, Integer page, Integer pageSize) {


        IPage<BlackList> pager = new Page<>(page, pageSize);
        QueryWrapper<BlackList> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId).orderByDesc("created");
        IPage<BlackList> blackListIPage = blackListMapper.selectPage(pager, wrapper);
        return blackListIPage;
    }
}
